<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <!-- vue3里面一起用的时候，v-if比v-for的优先级更高了 -->
        <!-- 1. 如果判断条件和item有关，推荐使用计算属性先过滤 -->
        <li v-for="item in oddList">{{ item }}</li>
      </ul>

      <!-- 2. 如果判断条件和item无关，推荐将v-if移到外层， 可以不这样做了 -->
      <p v-for="item in list2" v-if="show">{{ item }}</p>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            list: [1, 2, 3, 4, 5, 6, 7],
            list2: ["zhangsan", "lisi", "wangwu"],
            show: true,
          };
        },
        computed: {
          oddList() {
            return this.list.filter((item) => item % 2);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
